package io.github.veigara.tcp.device;

import io.github.veigara.tcp.framework.DeviceAccessFramework;
import io.github.veigara.tcp.framework.model.DeviceType;
import io.github.veigara.tcp.framework.model.LengthDecodeConfig;
import io.github.veigara.tcp.framework.model.NettyConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;

/**
 * @author : zhouhx
 * 启动服务端口
 * @date : 2025/6/9 13:49
 */
@Configuration
public class DeviceStartServer {
    @Autowired
    DeviceAccessFramework deviceAccessFramework;

    @Value("${netty.chargingple.port:8081}")
    private int chargingplePort;

    @PostConstruct
    public void init() {
        // 注册充电机设备服务器
        deviceAccessFramework.registerDeviceServer(DeviceType.CHARGING_PILE, chargingplePort,new NettyConfig(),new LengthDecodeConfig());

        // 启动所有服务器
        deviceAccessFramework.startAllServers();
    }
}
